package edu.jhu.cs.oose.scheduleit.services;

import java.util.List;

import edu.jhu.cs.oose.scheduleit.services.impl.DataBaseException;
import edu.jhu.cs.oose.scheduleit.util.Attribute;
import edu.jhu.cs.oose.scheduleit.util.DateWrapper;
import edu.jhu.cs.oose.scheduleit.vo.Event;
import edu.jhu.cs.oose.scheduleit.vo.Schedule;
import edu.jhu.cs.oose.scheduleit.vo.User;

/**
 * An interface for service related to Event
 * @author oose_group2
 * 
 *
 */
public interface EventService {
	
	/**
	 * Create a new event
	 * @param user	The owner who creates the new event
	 * @param schedule	The schedule to which the new event belongs
	 * @param attribute	The attribute of the new event
	 * @return	The new event created             
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public Event createNewEvent(User user, Schedule schedule, Attribute attribute) throws DataBaseException;
	
	/**
	 * Add some existed event to a existed schedule
	 * @param schedule	The existed schedules hosts the existed event 
	 * @param event	The existed event going to be added.
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public void addEvent(Schedule schedule, Event event) throws DataBaseException;
	
	/**
	 * A non-host user join some event created by others
	 * @param event	The objective event a non-host user wants to join in 
	 * @param user	The user who wants to join a special event
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public void joinEvent(Event event, User user) throws DataBaseException;
	
	/**
	 * A joined user of certain event quits this event
	 * @param event	The event which a joined user wants to quit
	 * @param user	The user who will quit a joined event
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public void quitEvent(Event event, User user) throws DataBaseException;
	
	/**
	 * Update the information of an event, for example, topic, start time, end time, and description.
	 * @param event	The event going to be updated
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public void updateEvent(Event event) throws DataBaseException;
	
	/**
	 * Remove an existed event
	 * @param schedule	The schedule hosting the event which going to be removed
	 * @param event	The event going to be removed
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public void removeEvent(Schedule schedule, Event event) throws DataBaseException;
	
	/**
	 * Retrieve the events according to the given time range.
	 * @param schedule	The schedule hosting the objective events.
	 * @param startTime The time which is earlier than the start time of the objective events.
	 * @param endTime	The time which is later than the end time of the objective events.
	 * @return	The event lists meeting the given time range.
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public List<Event> getEvents(Schedule schedule, DateWrapper startTime, DateWrapper endTime) throws DataBaseException;
	
	/**
	 * Retrieve all of the events belonged to a certain schedule
	 * @param schedule	The schedule hosting the objective events
	 * @return	All of the events in the given schedule
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public List<Event> getEvents(Schedule schedule) throws DataBaseException;
	
	/**
	 * Retrieve an event with the given id
	 * @param eventID	The id of the objective event
	 * @return	The event with the given id
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public Event getEvent(int eventID) throws DataBaseException;
	
	/**
	 * Calculate how many events satisfying the given time range.
	 * @param schedule	The schedule hosting the objective events
	 * @param startTime The time which is earlier than the start time of the objective events.
	 * @param endTime	The time which is later than the end time of the objective events.
	 * @return	The number of how many events satisfying the given conditions
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public int getEventCount(Schedule schedule, DateWrapper startTime, DateWrapper endTime) throws DataBaseException;
	
	/**
	 * Calculate how many events in a certain schedule
	 * @param schedule	The schedule hosting the objective event
	 * @return	The number of how many events in a certain schedule
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public int getEventCount(Schedule schedule) throws DataBaseException;
	
}
